package zjh_20230313;

import java.util.HashMap;
import java.util.Scanner;

public class Demo03 {
    public static void main(String[] args) {
        HashMap<Character, Integer> hashMap = new HashMap<>();
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入字符串：");
        String s = scanner.next();
        for (int i = 0; i < s.length(); i++) {
            char c = s.charAt(i);
            if (!hashMap.containsKey(c))
            {
                hashMap.put(c,1);
            }else {
                Integer sum = (Integer) hashMap.get(c);
                sum ++;
                hashMap.put(c,sum);
            }
        }
        System.out.println(hashMap);
    }
}
